package com.wandian.core
{
	import com.wandian.view.layer.BaseLayer;

	import flash.geom.Point;
	import flash.utils.Dictionary;

	/**
	 * 图层管理器
	 * @author leo
	 *
	 */
	public class LayerManager
	{
		private static var _instance:LayerManager=null;
		/**
		 * 所有图层管理
		 */
		public var layerDict:Dictionary;

		public function LayerManager(prvClass:PrivateClass)
		{
			this.layerDict=new Dictionary();
		}

		/**
		 * 根据层名字获取层实例
		 * @param name
		 * @return
		 *
		 */
		public function getLayer(name:String):*
		{
			var layer:BaseLayer;
			if (this.layerDict[name])
			{
				layer=this.layerDict[name];
			}
			else
			{
				trace("没有这个图层" + name);
			}
			return layer;
		}

		/**
		 * 更新所有层的显示位置
		 * @param speedX
		 * @param speedY
		 * @param p
		 *
		 */
		public function updateLayer(speedX:Number, speedY:Number, p:Point=null):void
		{
			if (this.layerDict)
			{
				for each (var layer:BaseLayer in this.layerDict)
				{
					layer.updatePosition();
				}
			}
		}

		public static function get instance():LayerManager
		{
			if (_instance == null)
			{
				_instance=new LayerManager(new PrivateClass());
			}
			return _instance;
		}

	}
}

class PrivateClass
{
}
